#include "qlogdatadialog.h"

#include "../libs/core/qlogdatabaseview.h"

#include <QFileDialog>
#include <QVBoxLayout>
#include <QAction>

QLogDataDialog::QLogDataDialog(QWidget *parent):
    QBaseDialog(parent),
    m_log_view(new QLogDatabaseView)
{
    QVBoxLayout *v=new QVBoxLayout;
    v->setMargin(0);
    v->setSpacing(0);
    v->addWidget(m_log_view);

    setLayout(v);

    QList<QAction*> list;
    QAction* ac;
    ac=new QAction(this);
    ac->setText(tr("Open"));
    ac->setIcon(QIcon(":/images/textfile.png"));
    connect(ac,SIGNAL(triggered()),this,SLOT(open()));
    list.append(ac);

    m_log_view->set_tool_bar(list);

    resize(800,600);
}

void QLogDataDialog::open()
{
    QString str=QFileDialog::getOpenFileName(this,tr("Open"),QDir::currentPath(),
                                             tr("DB File(*.db)"));
    if(str!="")
    {
        m_log_view->load(str);
    }
}
